package cn.edu.scau.cmi.chenyipeng.singleton;

public class Marshal {
		private static int count = 0;
		private static Marshal []ten_Marshal= new Marshal[10];
		private String name;
		
		private Marshal(String name) {
			this.name = name;
		}
		
		public static Marshal getInstance(String name) {
			if(count < 10 && !name.equals(null)) {
				ten_Marshal[count] = new Marshal(name);
				count++;
			}
			else if(count >= 10) {
				System.out.println("创建已达上限");
			}
			return ten_Marshal[count-1];
		}
		
		public String getName() {
			return name;
		}
		
		public static int getCount() {
			return  count;
		}
		public void setName(String name) {
			this.name = name;
		}
		
		public void doSometing() {
			System.out.println("我是"+name);
		}
		
		public String toString() {
			return this.name + super.toString();
		}
}
